<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 

/**
 * SimpleAuthenticator
 *
 * @package     AuthenticatedController
 * @subpackage  SimpleAuthenticator
 * @author      Doug Everly
 */

require(APPPATH."libraries/auth/Authenticator.php");

class SimpleAuthenticator extends Authenticator {

    function __construct()
    {
        parent::__construct();
    }

    
    function login($username, $password)
    {
        //  Username => Password
        $users = array(
            'joe'   => 'cat',
            'larry' => 'frog',
            'curly' => 'mouse',
            'moe'   => 'dog'
            );

        //  Username => Group
        $groups = array(
            'joe'   => 'admin',
            'larry' => 'admin',
            'curly' => 'user',
            'mode'  => 'user'
            );
        
        //  Default group
				if (@array_key_exists($username, $users))
				{
					
					if ($users[$username] == $password)
					{
						$group = $groups[$username];
						$this->make_session($username, $group);
						return 1;
					}
					else
					{
							return 0;
					}
        }
		else
		{
			return 0;
		}
    }

}

